<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>table</title>
    <link rel="stylesheet" type="text/css" href="http://unpkg.com/iview/dist/styles/iview.css">
    <script type="text/javascript" src="http://vuejs.org/js/vue.min.js"></script>
    <script type="text/javascript" src="http://unpkg.com/iview/dist/iview.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
</head>
<body>
<div id="app" style="padding: 20px">
    <div style="margin-bottom: 20px;float: right">
        <i-button type="ghost" @click="exportExcel" >excel 导出</i-button>
    </div>
    <div style="clear:both;"></div>
    <i-table stripe :columns="columns" :data="data"></i-table>
    <div style="float: right;margin-top: 20px">
        <page :current.sync="page" :total="totalElements" show-elevator  show-total @on-page-size-change="changePageSize"></page>
    </div>

</div>
<script>
    new Vue({
        el: '#app',
        data: {
            columns: [
                {
                    title: '编号',
                    key: 'id'
                },
                {
                    title: 'demo',
                    key: 'demo'
                }
            ],
            data: [],
            page: 1,
            totalElements: 0,
            pageSize: 10
        },
        mounted: function () {
            this.loadData()
        },
        methods: {
            loadData: function () {
                var self = this;
                var params = {
                    page: this.page - 1,
                    size: this.pageSize
                };
                axios.get('/demo', {params: params}).then(function (data) {
                    self.data = data.data.content;
                    self.totalElements = data.data.totalElements
                })
            },
            changePageSize: function (pageSize) {
                this.pageSize = pageSize
                this.loadData()
            },
            exportExcel: function () {
                window.location.href = '/demo/export'
            }
        }
    })
</script>
</body>
</html>